//package com.ag.answergames.service.wallet.impl;
//
//import com.ag.answergames.entity.ChildAccountEntity;
//import com.ag.answergames.mapper.wallet.ChildBalanceMapper;
//import com.ag.answergames.service.wallet.ChildBalanceService;
//import com.ag.answergames.vo.common.Result;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
///**
// * @author: aoaowu
// * @program: answer-game
// * @description: 关于小孩零钱罐的查找 获取
// * @create: 2023/04/21 17:34
// **/
//@Service
//public class ChildBalanceServiceImpl implements ChildBalanceService {
//
//    @Autowired
//    ChildBalanceMapper childBalanceMapper;
//
//    /**
//    * @Author: aoaowu
//    * @Description: 查询零钱罐余额
//    * @Param: [openId]
//    * @return: com.ag.answergames.vo.common.Result
//    * @Date: 2023/4/21
//    */
//    @Override
//    public Result find(String openId) {
//        QueryWrapper queryWrapper = new QueryWrapper();
//        queryWrapper.eq("open_id", openId);
//        ChildAccountEntity childAccountEntity = childBalanceMapper.selectOne(queryWrapper);
//        if (childAccountEntity != null && childAccountEntity.getBalance() != null) {
//            return Result.success(childAccountEntity.getBalance());
//        } else {
//            return Result.failed("余额显示出错");
//        }
//    }
//
//    @Override
//    public Result earn(Long money,String openId) {
//        Result result = find(openId);
//        Long oldBalance = (Long) result.getData();
//        Long newBalance = oldBalance + money;
//        ChildAccountEntity childAccountEntity = new ChildAccountEntity();
//        childAccountEntity.setBalance(newBalance);
//        UpdateWrapper<ChildAccountEntity> updateWrapper = new UpdateWrapper<>();
//        updateWrapper.eq("open_id",openId);
//        int update = childBalanceMapper.update(childAccountEntity, updateWrapper);
//        return Result.success(update);
//    }
//
//    @Override
//    public Result withdraw(Long money) {
//        return null;
//    }
//}
